+++ /dev/null
-#!/usr/bin/perl
-
-############################################################################################################
-#
-# GPX Coordinate corrector
-# 3/17/2004
-#
-# Takes a GPX Spinner-formatted CorrectedCaches.txt file and substitutes the coordinates into a GPX file
-# most likely from a Geocaching pocket query, based on the short name (GCXXXX).
-# Useful for updating coordinates for puzzle caches or changing to the next stage of a multi-cache.
-# Caches that appear in the corrections file but are not in the GPX are ignored.
-#
-# Usage:
-# correctCoordinates.pl my.gpx CorrectedCaches.txt > corrected.gpx
-#
-# requires XML::Twig
-#
-# Jeff Boulter <jeff@boulter.com>
-#
-############################################################################################################
-
-use strict;
-use XML::Twig;
-
-my $fname = $ARGV[0];
-my $correctFile = $ARGV[1];
-
-open(CORR, $correctFile) || die "can't find corrections file: $!";
-
-my %correct;
-
-while (<CORR>)
-{
- s/\#.*//;
- tr/\r//d;
- chomp;
- my $line = trim($_);
- if ($line)
- {
-# print "\"$line\"\n";
- my($wp, $lat, $lon) = split(/\,/, $line);
-# print "coords: $wp $lat $lon\n";
-
- $correct{$wp} = {'lat' => coordsToDec(trim($lat)), 'lon' => coordsToDec(trim($lon))};
- }
-}
-
-close(CORR);
-
-my $twig = XML::Twig->new(
- twig_roots => { 'wpt' => \&wpt,
- },
- twig_print_outside_roots => 1, # print the rest
-);
-
-$twig->parsefile($fname); # build the twig
-
-sub trim
-{
- my $str = $_[0];
- $str =~ s/\s*(.*\S)\s*/$1/;
- return $str;
-}
-
-sub coordsToDec
-{
- my $CoordString = @_[0];
- my $Result = 0;
- if ($CoordString =~ /\s*([N|S|E|W])\D*(\d+)\D*([\d|.]+)/i) {
- my $Direction = uc($1);
- $Result = $2 + $3 / 60.;
- if ($Direction eq 'S' || $Direction eq 'W') {
- $Result = -$Result;
- }
- }
- elsif ($CoordString =~ /\s*-{0,1}\d+\.\d+/) {
- $Result = $CoordString;
- }
- return $Result;
-}
-
-
- sub wpt
-{
- my( $t, $wpt)= @_; # arguments for all twig_handlers
- my $title = $wpt->first_child( 'name')->text; # find the title
-
- if ($correct{$title})
- {
-# print STDERR "correcting " . $wpt->first_child( 'urlname')->text . "\n";
- $wpt->set_att('lat' => $correct{$title}->{'lat'});
- $wpt->set_att('lon' => $correct{$title}->{'lon'});
- }
-
- # bug in Twig doesn't keep > escaped
- $wpt->subs_text( qr{>}, '&ent( ">")');
-
- $wpt->flush; # outputs the section and frees memory
- }
-
+++ /dev/null
-From: David Slimp
-Date 02/09/04
-Subject: [Gpsbabel-misc] gpx2xfig and transparent gif
-
-Hello All,
-
-I don't know if anyone would be interested in this or not,
-but I've created a small perl script that will convert a gpx
-file to an xfig data file, so I could then take track
-information and edit in a visual way, and then using fig2dev
-I create a transparent gif of my track/route.
-
-I was planning to use this as an overlay for a Yahoo or
-MapQuest map, but after driving a couple miles and then
-trying to fit my track path over the Yahoo map for that area
-it seemed to be a bit off -- rotation wise. At first I
-thought it might be the difference between true north and
-magnetic north, but appearantly not.
-
-Anyway, in case anyone out there might benefit from this or
-want to work on it more here's my script and sample linux
-command lines:
-
-==================== gpx2xfig ===============================
-#!/usr/bin/perl -w
-#
-# gpx2xfig - converts GPS gpx file to xfig vector file
-#
-# author: David Slimp <rock808@DavidSlimp.com>
-# created: 20040206
-# updated: 20040208
-
-$VERSION=".001";
-
-($infl,$outfl)=@ARGV;
-
-open(IN,"$infl") or die "$!";
-open(OUT,">$outfl") or die "$!";
-
-while (<IN>) {
- s/<trkpt lat="(.*?)" lon="(.*?)".*/$2 -$1/ and s/\.//g and push(@TrkPts,"$_");
-}
-close IN;
-
-
-print OUT "#FIG 3.2\n",
- "Landscape\n",
- "Center\n",
- "Inches\n",
- "Letter \n",
- "100.00\n",
- "Single\n",
- "-2\n",
- "1200 2\n",
- "2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 ",scalar(@TrkPts),"\n";
-foreach (@TrkPts) {
- print OUT ;
-}
-close OUT;
-=============================================================
-
-
-To convert the gpx file to xfig file:
- $ ./gpx2xfig Tracks.gpx Tracks.xfig
-
-To create the transparent gif:
- $ fig2dev -Lgif -t"#ffffff" -m.11 -b50 Tracks.xfig Tracks.gif
-
-(of course, you must have transfig package installed)
-
-
-
-